home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / MORSETUP.ZIP / APPSECTN.C < prev    next >
C/C++ Source or Header  |  1993-05-06  |  3KB  |  95 lines

  1. #define STRICT
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <string.h>
  5. #include <stdio.h>
  6. #include "morsetup.h"
  7.  
  8. /*-------------------------------------------------------------------------*/
  9. BOOL WINAPI SectionDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  10.     {
  11.     static DLGPROC   lpfnSaveDlgProc;
  12.     HDC     hDC;
  13.     RECT    rc;
  14.     PAINTSTRUCT ps;
  15.     char IniString[20], NewSectionName[MAXFILECHARS], CurrentSectionName[MAXFILECHARS];
  16.     int i, SectionNumber, Index;
  17.  
  18.     switch(message)
  19.     {
  20.     case WM_INITDIALOG:
  21.         SetDlgItemText(hDlg, IDSECTION_CURRENT, AppSystem.SectionName);
  22.         for(i=0;i<AppSystem.NumberOfSections;i++)
  23.         {
  24.         sprintf(IniString,"%d",i+1);
  25.         GetPrivateProfileString(INI_APPMORE, IniString, SECTIONNAME_DEFAULT,
  26.                 szBuffer, MAXFILECHARS-1, INI_FILE);
  27.         SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_ADDSTRING, 0, (LONG) szBuffer);
  28.         }
  29.         return TRUE;
  30.  
  31.     case WM_COMMAND:
  32.         switch(wParam)
  33.         {
  34.         case IDSECTION_ADD:
  35.             GetDlgItemText(hDlg, IDSECTION_NEW, NewSectionName, MAXFILECHARS-1);
  36.             AddSectionName(NewSectionName);
  37.             SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_ADDSTRING, 0, (LONG) NewSectionName);
  38.             strcpy(NewSectionName, "");
  39.             SetDlgItemText(hDlg, IDSECTION_NEW, NewSectionName);
  40.             return TRUE;
  41.  
  42.         case IDSECTION_NEW:
  43.             if(HIWORD(lParam) == EN_KILLFOCUS)
  44.             {
  45.             GetDlgItemText(hDlg, IDSECTION_NEW, NewSectionName, MAXFILECHARS-1);
  46.             SetDlgItemText(hDlg, IDSECTION_NEW, NewSectionName);
  47.             }
  48.             return TRUE;
  49.  
  50.         case IDSECTION_OK:
  51.             Index = (WORD) SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_GETCURSEL, 0, 0L);
  52.             SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_GETTEXT, Index, (LONG) CurrentSectionName);
  53.             if(bSave && (stricmp(AppSystem.SectionName, "<none>") != 0))
  54.             {
  55.             lpfnSaveDlgProc = (DLGPROC) MakeProcInstance(SaveDlgProc, hInst);
  56.             DialogBox(hInst, "SaveDlg", hDlg, lpfnSaveDlgProc);
  57.             FreeProcInstance((FARPROC) lpfnSaveDlgProc);
  58.             }
  59.             SectionNumber = VerifySectionName(CurrentSectionName);
  60.             if(SectionNumber)
  61.             {
  62.             AppSystem.SectionNumber = SectionNumber;
  63.             IniRead();
  64.             for(i=0;i<MAXAPPS;i++)
  65.                 LoadIconFromFile(&hIcon[i], i);
  66.             for(i=0;i<NUMICONS;i++)
  67.                 bCurrentIcon[i] = FALSE;
  68.             iBlackIcon = 0;
  69.             iCurrent = 0;
  70.             bCurrentIcon[iBlackIcon] = TRUE;
  71.             SetScrollPos(hwndScroll, SB_CTL, 0, TRUE);
  72.             UpdateScrollIcons(iBlackIcon);
  73.             Button_SetCheck(hwndCloseProg, AppButton[iCurrent].Close);
  74.             Button_SetCheck(hwndButtonLook, AppButton[iCurrent].ButtonLook);
  75.             bSave = FALSE;
  76.             }
  77.             EndDialog(hDlg, 0);
  78.             return TRUE;
  79.  
  80.         case IDSECTION_DELETE:
  81.             Index = (WORD) SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_GETCURSEL, 0, 0L);
  82.             SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_GETTEXT, Index, (LONG) CurrentSectionName);
  83.             DeleteSectionName(CurrentSectionName);
  84.             SendDlgItemMessage(hDlg, IDSECTION_LIST, LB_DELETESTRING, Index, 0L);
  85.             return TRUE;
  86.  
  87.         case IDSECTION_CANCEL:
  88.             EndDialog(hDlg, 0);
  89.             return TRUE;
  90.         }
  91.         break;
  92.     }
  93.     return FALSE;
  94.     }
  95.